package net.apexes.demo.codegen.dslite.qvar;

import java.time.LocalDateTime;
import net.apexes.demo.codegen.dslite.entity.PriceStrategy;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QPriceStrategy is a DSLite query type for PriceStrategy
 * @see PriceStrategy
 */
public class QPriceStrategy extends QEntityBase<PriceStrategy> {

    public static final QPriceStrategy $ = new QPriceStrategy("PRICE_STRATEGY");

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public final StringColumn name = varchar("NAME", 32).field("name").notNull().build();

    public final StringColumn description = varchar("DESCRIPTION", 128).field("description").build();

    public final TemporalColumn<LocalDateTime> effectiveTime = datetime("EFFECTIVE_TIME").field("effectiveTime").notNull().build();

    public final TemporalColumn<LocalDateTime> expireTime = datetime("EXPIRE_TIME").field("expireTime").build();

    public class Indexs {

        public final Index constraintIndex9 = index("CONSTRAINT_INDEX_9").column(templateId).build();

        public final Index primaryKey9 = index("PRIMARY_KEY_9").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint9b = foreignKey(templateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QPriceStrategy(String tableName) {
        super(PriceStrategy.class, tableName);
    }

    @Override
    public PriceStrategy newEntity() {
        return new PriceStrategy();
    }

    @Override
    public Object getFieldValue(PriceStrategy entity, String fieldName) {
        switch (fieldName) {
            case "templateId":
                return entity.getTemplateId();
            case "name":
                return entity.getName();
            case "description":
                return entity.getDescription();
            case "effectiveTime":
                return entity.getEffectiveTime();
            case "expireTime":
                return entity.getExpireTime();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(PriceStrategy entity, String fieldName, Object value) {
        switch (fieldName) {
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            case "name":
                entity.setName((java.lang.String) value);
                break;
            case "description":
                entity.setDescription((java.lang.String) value);
                break;
            case "effectiveTime":
                entity.setEffectiveTime((java.time.LocalDateTime) value);
                break;
            case "expireTime":
                entity.setExpireTime((java.time.LocalDateTime) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

